#include<bits/stdc++.h>
#define ll long long
using namespace std;
int t;
int n,m,l,V;
int p[100010],d[100010],v[100100],a[100010];
int cs[100010],jc[100010];
bool csm(int x,int sx,int t)
{
    double val=sqrt(sx*sx+2*x*t);
    if(val>double(V))return 1;
    return 0;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--)
    {
        for(int i=1;i<=100003;i++)
        {
            cs[i]=0;
        }
        cin>>n>>m>>l>>V;
        bool ai=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            if(a[i]<0)ai=1;
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&p[i]);
        }
        for(int i=1;i<=n;i++)
        {
            if(v[i]>V&&d[i]<=p[m])
            {
                cs[i]=1;
                continue;
            }
            else 
            if(d[i]<=p[m]){
                if(csm(a[i],v[i],(p[m]-d[i])))cs[i]=1;
            }
        }
        if(ai==0)
        {
            int ans=0;
            for(int i=1;i<=n;i++)
            {
                if(cs[i]==1)ans++;
            }
            if(ans)cout<<ans<<' '<<m-1<<endl;
            else cout<<ans<<' '<<m<<endl;
            continue;
        }
    }
    return 0;
}